package com.geez.bbl.util;

import java.util.HashMap;
import java.util.Map;

/**
 * User: biniam.gebremichael
 * Date: Jul 16, 2010
 */
public class GeezUtil {


    static Map<String, String> sera = FileUtils.processCSV(ProjectResources.getResourceFile("translate", "sera.csv"));

    public static boolean isGeez(String s){
        return (s.length()>0&& (s.charAt(0)>4000 || s.equals(" ")|| s.equals("\t") || s.equals("-")|| s.equals(":")));
    }

    public static String removeLatin(String vs){
        if(vs==null||vs.length()<1){
                                  return vs;
        }

        StringBuilder builder = new StringBuilder();
        for (String s : vs.split("")) {
            if(s.length()>0&& (s.charAt(0)>4000 || s.equals(" "))){
                builder.append(s);
            }

    }
        return builder.toString().trim();
    }

     public static String toSera(String utf8) {
        StringBuilder builder = new StringBuilder();
        for (String str : utf8.split("\\s+")) {

            for (char s : str.toCharArray()) {
                String seraString = sera.get(String.valueOf((int) s));
                if (seraString != null) {
                    builder.append(seraString);
                }
            }
            builder.append(" ");
        }
        return builder.toString().trim();
    }

     public static String removeVowel(String s) {
        return s.replaceAll("[a|e|i|o|u|A|E|I|O|U|\\'|\\`|_]", "");
    }

}

